<%@ taglib prefix="fn2" uri="http://java.sun.com/jsp/jstl/functions" %>

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,member-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
<link href="css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="css/pagination.css" rel="stylesheet" type="text/css" />	
<link href="lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet"
	type="text/css" />
<!--[if IE 6]>
<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>T_shipping管理</title>

</head>
<body>
	<div class="pd-20">

		<div class="mt-20">
			<table
				class="table table-border table-bordered table-hover table-bg table-sort">
				<thead>
					<tr class="text-c">

                        <th width="100">编号</th>
                        <th width="100">配送员</th>
                        <th width="100">配送地区</th>
                        <th width="100">联系电话</th>
                        <th width="100">当前状态</th>
						<th width="50">正在配送的订单</th>
						<th width="100">好评率</th>
						<th width="100">准时率</th>
						<th width="200">操作</th>
					</tr>
				</thead>
				<tbody>
						<c:forEach items="${shippers}" var="shipper">
						
						<tr class="text-c">
							<input type="hidden" id="id" name="id"
								value='${shipper.user_id}' />
         
                            <td>${shipper.user_id}</td>
                            <td>${shipper.c_tname}</td>
                            <td>${shipper.c_city}</td>
                            <td>${shipper.c_mob}</td>
                            <c:if test="${shipper.working_status==0}">
                            	<td>离岗</td>
                            </c:if>
                            <c:if test="${shipper.working_status==2}">
                            	<td>休息</td>
                            </c:if>
                            <c:if test="${shipper.working_status==1&&shipper.titles==''}">
                            	<td>空闲</td>
                            </c:if>
                            <c:if test="${shipper.working_status==1&&shipper.titles!=''}">
                            	<td>配送中</td>
                            </c:if>
                            
                            <td>
                            <c:forEach items="${fn2:split(shipper.titles,',')}" var="title">
                            <a style="text-decoration:none"
								onClick="t_shipping_edit(this,'${title}')" href="javascript:void(0);"
								title="详情">${title}</a>
                            </c:forEach>
                            </td>
                            <td>${shipper.remark}</td>
                            <td>${shipper.ontime}</td>
                            
							<td class="td-manage">
								<a style="text-decoration:none"
								onClick="t_shipping_allocate(this,'${shipping_id}','${titles}','${shipper.user_id}','${thetype}')" href="javascript:void(0);"
								title="立即派单">立即派单</a>
							</td>
						</tr>
					</c:forEach>
				</tbody>
			</table>
			<div id="Pagination" class="page-con"></div>
		</div>
	</div>
	<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
	<script type="text/javascript" src="lib/layer/1.9.3/layer.js"></script>
	<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
	<script type="text/javascript" src="lib/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript"
		src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
	<script type="text/javascript" src="js/H-ui.js"></script>
	<script type="text/javascript" src="js/H-ui.admin.js"></script>
	<script type="text/javascript" src="js/jquery.pagination.js"></script>	
	<script type="text/javascript">
		$(function() {
			initPager();
		});
		
		var showCount = ${pageInfo.showCount};
		var currentPage = ${pageInfo.currentPage-1};
		var totalResult = ${pageInfo.totalResult};
		function initPager(){
			$("#Pagination").pagination(totalResult, {
	            callback: function(new_page_index, pagination_container){
	            	var oldLocation = location.href;
	            	var pa = "currentPage=" + (new_page_index+1);
	        		var shoC = "showCount=" + showCount;
	            	var index = oldLocation.lastIndexOf("?");
	            	if (index == -1){
	            		location.href = oldLocation + "?" + pa + "&" + shoC;
	            	}else if (oldLocation.indexOf("currentPage") == -1){
	            		location.href = oldLocation + "&" + pa;
	            	}else if (oldLocation.indexOf("showCount") == -1){
	            		location.href = oldLocation + "&" + shoC;
	            	}else{
	            		var temp = oldLocation.replace(/currentPage=\d+/, pa);
						var newLocation = temp.replace(/showCount=\d+/, shoC);
	            		location.href = newLocation;
	            	}
	            	return false;
	            },
	            items_per_page:showCount, 
	            load_first_page:false,
	            prev_text:'上一页',
	            next_text:'下一页',
	            ellipse_text:'...',
	            num_edge_entries:1,
	            num_display_entries:5,
	            current_page:currentPage,
	        });
		}
		
		/*重置*/
		function type_reset(url){
			window.location = url;
		}

		/*派单*/
		function t_shipping_allocate(obj,id,title,userid,thetype,w,h){
			// var edit_page = ?id="+id+"&order_id="+title+"&user_id="+userid,{"orderId":orderId,"commant":commant}, ;
			$.ajax({
				type : "POST",
				url : "<%=path%>/backstage/t_shipping-allocate_ht",
				data : {"id":id,"order_id":title,"user_id":userid},
				error : function() {
					layer.msg('派单失败！', {icon:5,time:1000});
				},
				success : function(msg) {
					layer.msg('派单成功！ ' + msg.information, {icon:6,time:1000});
					$(obj).parents("body").find(".btn-refresh").click();
					var index = parent.layer.getFrameIndex(window.name);
					if(thetype==1){
						parent.location.href = "<%=path%>/backstage/t_shipping_listbyterm?status=2&message=1";
					}else{
						parent.location.href = "<%=path%>/backstage/t_shipping_wait_listbyterm?message=1";
					}
					parent.layer.close(index);
				}
			});
		}
		/*详情*/
		function t_shipping_edit(obj,titles,w,h){
			var edit_page = "<%=path%>/backstage/order-detailsbytitles?titles="+titles;
			layer_show("详情",edit_page,w,h);
		}
		
	</script>
</body>
</html>



